#include <cstdio> 
#include <iostream>
#include <cstring>
#include <numeric>
#include <algorithm>
using namespace std;
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}

inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
#define DEBUG
#define mod(x) (x%MOD+MOD)%MOD
using ll=long long;
const int N=1e6+10, M=110, MOD=998244353;
int n;
int A[N];
int GCD[N][N]; //GCD[l][r]:(l,r)的最小公约数
ll ans=0;

// 计算最大公约数
int gcd(int a, int b) {
    return b==0?a:gcd(b, a%b);
}

void init()
{
    memset(GCD, -1, sizeof GCD);
	read(n);
	for(int i=1; i<=n; i++)
		read(A[i]), GCD[i][i]=A[i];

}

inline int f(int l, int r)
{	
	if(l==r) return GCD[l][r]=A[l];
	if(GCD[l][r]!=-1) return GCD[l][r];
	return GCD[l][r]=gcd(A[l], f(l+1, r)); //记忆化搜索 
}

void make()
{
    for(int l=1; l<=n; l++)
		for(int r=l; r<=n; r++)
        {
            if(l==r) continue;
            else if(r==l+1) GCD[l][r]=A[l];
            else GCD[l][r]=gcd(GCD[l][r-1], GCD[r][r]);
        }
}

void solve()
{
    init();
    for(int l=1; l<=n; l++)
		for(int r=l; r<=n; r++)
			ans=mod(ans+1ll*l*r*GCD[l][r]);	
	write(ans); puts("");
}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}